package com.springboot.service.impl;

import com.springboot.dao.GoodsInfoMapper;
import com.springboot.entity.GoodsInfo;
import com.springboot.service.TestService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.List;

/**
 * @Author lizhilong
 * @create 2020/3/10 16:27
 * @desc
 */
@Service
public class TestServiceImpl implements TestService {
    @Autowired
    private GoodsInfoMapper goodsInfoMapper;

    @Override
    //@DataSource(DataSourceType.SLAVE)
    public List<GoodsInfo> selectAll() {
        return goodsInfoMapper.selectAll();
    }

    @Override
    public int save() {
        GoodsInfo goodsInfo = new GoodsInfo();
        goodsInfo.setGoodsName("炸鸡");
        goodsInfo.setGoodsPrice(new BigDecimal(10.22));
        goodsInfo.setGoodsType("2");
        goodsInfo.setInputTime(LocalDateTime.now());
        return goodsInfoMapper.insert(goodsInfo);
    }
}
